<template>
  <div id="app">
    <router-view />
  </div>
</template>
<script>
export default {
  data() {
    return {};
  },
  created() {
    this.notification();
  },
  watch:{
   $route(to,from){
   }
},
  mounted() {
    // if (!localStorage.getItem("token")) {
    //   this.$Message["error"]({
    //     background: true,
    //     content: "请先登录"
    //   });
    //   this.$router.push("/login");
    // } else {
    //   this.$store.commit(
    //     "saveOpera",
    //     JSON.parse(sessionStorage.getItem("operations"))
    //   );
    //   this.$store.commit("saveToken", sessionStorage.getItem("token"));
    //   const operations = this.$store.state.operations;
    //   this.$store.dispatch("GenerateRoutes", { operations }).then(() => {
    //     this.$router.addRoutes(this.$store.state.addRouters);
    //     this.$router.addRoutes([{ path: "*", redirect: "/404", hidden: true }]);
    //   });
    // }

    // // 在页面刷新时将vuex里的信息保存到sessionStorage里
    // window.addEventListener("beforeunload", e => {
    //   sessionStorage.setItem("token", this.$store.state.token);
    //   sessionStorage.setItem(
    //     "operations",
    //     JSON.stringify(this.$store.state.operations)
    //   );
    // });
  },
  methods: {
    //申请浏览器通知权限，具体参见上面文档链接
    notification() {
      let that = this;
      if (!("Notification" in window)) {
        console.log("浏览器不支持消息通知");
        return;
      }
      Notification.requestPermission(function(permission) {});
    }
  }
};
</script>
<style lang="less">
@import "./assets/css/public.less";
</style>
